package edu.utd.text.game.controller.commands;

/**
 * BooleanCommand represents something like a yes/no
 * response from the user.
 * @author troy
 *
 */

public class BooleanCommand implements GameCommand {

	private boolean yes;
	private GameCommand commandToExecuteYes;	//should be init null?
	private GameCommand commandToExecuteNo;
	
	  //////////////////
	 // Constructors //
	//////////////////
	
	public BooleanCommand(boolean yes) {
		this.yes = yes;
	}
	
	
	public BooleanCommand(boolean yes, 
			GameCommand commandToExecuteYes)
	{
		this.yes = yes;
		this.commandToExecuteYes = commandToExecuteYes;
	}
	
	
	public BooleanCommand(
			boolean yes, 
			GameCommand commandToExecuteYes, 
			GameCommand commandToExecuteNo) 
	{
		this.yes = yes;
		this.commandToExecuteYes = commandToExecuteYes;
		this.commandToExecuteNo = commandToExecuteNo;
	}
	
	
	  ///////////////////////
	 // methods and stuff //
	///////////////////////
	
	public boolean yes() { return yes; }
	
	public void setYes(boolean yup) { yes = yup; }
	
	//FIXME : Can this cause NPEs?
	public String execute() {
		try {
			if (yes) {
				return commandToExecuteYes.execute();
			} else {
				return commandToExecuteNo.execute();
			}
		} catch (Exception e) {
			return "It was a boolean question.  I'm not sure what you meant by that...";
		}
		
//		return "You found some code that isn't implemented yet.  Congratulations, detective.";
	}
	
	
}
